	<?php 
		$ci= &get_instance();
		$cat_id = intval($_POST['cat_id']);
		$CAT_MANUAL =  $ci->category_manual_entity->init('id', $cat_id);
		$userBetStatus = userBetStatusDataConfig();
		$listBetArray = $ci->bet_manual_entity->getBetList($CAT_MANUAL->getKeyId());
	?>
	Category: <?php echo $CAT_MANUAL->getCategoryName();?> <br/>
	<?php
		if($CAT_MANUAL->getType() == 'box'){
			echo "Number of Boxes: ".$CAT_MANUAL->getNumberBoxes();
		}else{
			echo "Range Denote: ".$CAT_MANUAL->getRangeDenote();
		}
	?>
	<br />
	Correct Answer: <?php if($CAT_MANUAL->getFixAnswer() == 1){ echo $CAT_MANUAL->getCorrectAnswer();}?>
	<div class="clrboth"></div>
	<input type="button" value="Apply Answer" onclick="apply_answer_to_category(<?php echo $cat_id;?>);" />
	<?php echo loader_image("id='loader_image_apply_answer' class='hidden'");?>
	<div class="clrboth"></div>
<table>
<thead>
	<th><div class="grid2"><span class="bold" style="font-weight:bold;">Username</span></div></th>
	<th><div class="grid3"><span class="bold" style="font-weight:bold;">Answer</span></div></th>
	<th><div class="grid1"><span class="bold" style="font-weight:bold;">Odds</span></div></th>
	<th><div class="grid1"><span class="bold" style="font-weight:bold;">Stake</span></div></th>
	<th><div class="grid2"><span class="bold" style="font-weight:bold;">Result</span></div></th>
	<th><div class="grid1"><span class="bold" style="font-weight:bold;">Status</span></div></th>
	<th><div class="grid3"><span class="bold" style="font-weight:bold;">Manage</span></div></th>
</thead>	
<tbody>
	<div class="clrboth"></div>
	<?php foreach($listBetArray as $item):?>
		<?php 
			$USER = $ci->user_entity->init('id', $item->user_id);
			$BET_MANUAL = $ci->bet_manual_entity->init('id', $item->id);
			$won = ($BET_MANUAL->getResult() == 'won') ? 'checked="checked"':'';
			$lost = ($BET_MANUAL->getResult() == 'lost') ? 'checked="checked"':'';
		?>
		<tr>
			<td><?php echo $USER->getUserName();?></td>
			<td>
			<?php
				if($CAT_MANUAL->getType() == 'box'){
					$answer_array = array_filter(explode('{[|SEPSTR|]}',$BET_MANUAL->getAnswer()));
					foreach($answer_array as $one){
						echo "- ".$one."<br/>";
					}
				}else{
					$answer_array = array_filter(explode('{[|SEPSTR|]}',$BET_MANUAL->getAnswer()));
					echo "From ".$answer_array[0]." To ".$answer_array[1];
				}
			?>
			</td>
			<td><?php echo $BET_MANUAL->getOdds();?></td>
			<td><?php echo $BET_MANUAL->getStake();?></td>
			<td>
				<?php if($BET_MANUAL->getStatus() == 'betting'):?>
					<input type="radio" name="bet_<?php echo $BET_MANUAL->getId();?>" value="won" <?php echo $won;?> onclick="set_bet_manual_event_result(<?php echo $BET_MANUAL->getId();?>,'won');" />Won
					<input type="radio" name="bet_<?php echo $BET_MANUAL->getId();?>" value="lost" <?php echo $lost;?> onclick="set_bet_manual_event_result(<?php echo $BET_MANUAL->getId();?>,'lost');" />Lost 
					<?php echo loader_image("id='loader_image_set_result_{$item->id}' class='hidden'");?>
				<?php else:?>
					<?php echo $BET_MANUAL->getResult();?>
				<?php endif;?>
			</td>
			<td><?php echo $userBetStatus[$BET_MANUAL->getStatus()];?></td>
			<td>
				<?php if($BET_MANUAL->getStatus() == 'betting'):?>
					<a href="javascript:void(0);" onclick="bet_manual_event_cancel(<?php echo $BET_MANUAL->getId();?>)" >Cancel</a>
					&nbsp;|&nbsp;
					<a href="javascript:void(0);" onclick="bet_manual_event_finish(<?php echo $BET_MANUAL->getId();?>)" >Finish</a>
					<?php echo loader_image("id='loader_image_manage_{$item->id}' class='hidden'");?>
				<?php endif;?>
			</td>
		</tr>
	<?php endforeach;?>
</tbody>
</table>	

